/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package camera;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.SwingWorker;

/**
 *
 * @author pedro
 */
public class HiloFoto extends AbstractAction {
    private MainFrame frame;
    private boolean running = false;
    final SwingWorker worker = new SwingWorker() {
            @Override
            protected Object doInBackground() throws Exception {
                running = true;
                while ( running ) {
                    frame.getImage();
                }
                return null;
            }
        };

    
    public HiloFoto( MainFrame frame ) {
        this.frame = frame;
    }
    
    @Override
    public void actionPerformed( ActionEvent e ) {
        worker.execute();
    }

    public void stop() {
        running = false;
    }
}
